package com.oodso.say.base;

import android.view.MotionEvent;
import android.view.View;

import com.oodso.say.utils.Constant;
import com.oodso.say.utils.EditTextUtil;
import com.oodso.say.utils.StorageUtil;

import org.simple.eventbus.Subscriber;

import java.io.File;

/**
 * Created by xulei on 2018/2/27.
 * 项目： com.oodso.say.base
 * 功能描述：
 * 备注：
 */

public abstract class SayActivity extends BaseActivity {
    public File getCacheDir() {
        return StorageUtil.getCacheDir();
    }


    @Override
    public String getPageName() {
        return this.getClass().getSimpleName();
    }


    @Subscriber(tag = Constant.EventBusTag.LOGBACKIN)
    public void logBackIn(String str) {
        finish();
    }


    @Override
    public int fragmentRoot() {
        return 0;
    }

    //软键盘点击其他区域消失
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {

        if (ev.getAction() == MotionEvent.ACTION_UP) {
            View v = getCurrentFocus();
            if (EditTextUtil.isShouldHideKeyboard(v, ev)) {
                EditTextUtil.hideKeyboard(this, v.getWindowToken());
            }
        }
        return super.dispatchTouchEvent(ev);
    }
}
